#define _CRT_SECURE_NO_WARNINGS 1
int* sortArray(int* nums, int numsSize, int* returnSize) {
    *returnSize = numsSize;
    int max = nums[0], min = nums[0];
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] > max)
        {
            max = nums[i];
        }
        if (nums[i] < min)
        {
            min = nums[i];
        }
    }
    int range = max - min + 1;
    int* count = (int*)malloc(sizeof(int) * range);
    for (int i = 0; i < range; i++)
    {
        count[i] = 0;
    }
    for (int i = 0; i < numsSize; i++)
    {
        count[nums[i] - min]++;
    }
    int j = 0;
    for (int i = 0; i < range; i++)
    {
        while (count[i]--)
        {
            nums[j++] = i + min;
        }
    }
    free(count);
    return nums;
}